home *** CD-ROM | disk | FTP | other *** search
- #include "FileMenu.h"
- #include "AppleEvent.h"
-
-
-
-
-
- extern Boolean gExitFlag;
- extern FileMenu *gFileMenu;
-
-
-
-
-
- void InitializeAppleEvents(void)
- {
- AEEventHandlerUPP AECoreProc;
-
-
- /* install the core AppleEvent handlers */
- AECoreProc = NewAEEventHandlerProc(AECoreHandler);
- AEInstallEventHandler(kCoreEventClass,kAEOpenApplication,AECoreProc,kAEOpenApplication,false);
- AEInstallEventHandler(kCoreEventClass,kAEOpenDocuments,AECoreProc,kAEOpenDocuments,false);
- AEInstallEventHandler(kCoreEventClass,kAEPrintDocuments,AECoreProc,kAEPrintDocuments,false);
- AEInstallEventHandler(kCoreEventClass,kAEQuitApplication,AECoreProc,kAEQuitApplication,false);
- }
-
-
-
-
-
- void ProcessAppleEvent(EventRecord *event)
- {
- AEProcessAppleEvent(event);
- }
-
-
-
-
-
- pascal SInt16 AECoreHandler(AppleEvent *aevent,AppleEvent *areply,long refcon)
- {
- /* use refcon to dispatch event */
- switch(refcon)
- {
- case kAEOpenApplication:
- break;
-
- case kAEOpenDocuments:
- break;
-
- case kAEPrintDocuments:
- break;
-
- case kAEQuitApplication:
- gExitFlag = true;
- break;
- }
-
- /* make sure event was properly handled */
- return (SInt16)AEGotRequiredParams(aevent);
- }
-
-
-
-
-
- SInt32 AEGotRequiredParams(AppleEvent *aevent)
- {
- DescType returnedType;
- Size actualSize;
- SInt32 err;
-
-
- /* did we extract all the required parameters? */
- err = AEGetAttributePtr(aevent,keyMissedKeywordAttr,typeWildCard,&returnedType,nil,0,&actualSize);
- if (err == errAEDescNotFound)
- {
- /* we got all the required parameters */
- return noErr;
- }
- else if (!err)
- {
- /* we missed a required parameter */
- return errAEEventNotHandled;
- }
-
- /* the call to AEGetAttributePtr failed: weird! */
- return err;
- }
-